package com.achievo.know.web.myfile;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.achievo.know.application.CategoryApplication;
import com.achievo.know.application.FileApplication;
import com.achievo.know.application.NewsApplication;
import com.achievo.know.component.impl.FileManagerConfig;
import com.achievo.know.domain.AttachmentType;
import com.achievo.know.domain.Category;
import com.achievo.know.domain.File;
import com.achievo.know.domain.FileAttachment;
import com.achievo.know.domain.FileAttachmentRepository;
import com.achievo.know.domain.News;
import com.achievo.know.domain.NewsContent;
import com.achievo.know.domain.TempAttachment;
import com.achievo.know.domain.UserFavorite;
import com.achievo.know.job.ConvertFileThread;
import com.achievo.know.pojo.Constants;
import com.achievo.know.pojo.FileFolder;
import com.achievo.know.pojo.FileHandle;
import com.achievo.know.pojo.FileStatus;
import com.achievo.know.pojo.JsonCategory;
import com.achievo.know.web.util.ExecutorUtil;
import com.achievo.know.web.util.PageActionSupport;
import com.dayatang.querychannel.support.Page;
import com.redhat.redwork.coc.RedworkAction;

public class MyfileAction extends PageActionSupport implements RedworkAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8691354212689678309L;
	
	private static final Logger	logger  = LoggerFactory.getLogger(MyfileAction.class);
	
	@Autowired
	public FileApplication fileApplication;
	@Autowired
	private CategoryApplication categoryApplication;
	@Autowired
	private NewsApplication newsApplication;
	@Autowired
    private FileManagerConfig config;
	
	private String status=FileStatus.SUBMITTING;//状态
	private Page<File> filePage;//查询列表
	private String curTab="SUBMITTING";//当前TAB
	private String ids;//选择删除的IDS
	private String jsonResult;//JSON操作结果
	private String jsonCode;
	private File file;
	private String fileId;//文件ID
	private String fileName;//文件Name
	private String tempFileId;//临时文件ID
	private List<TempAttachment>  tempAttachs;//临时附件
	private String attachId;//附件ID
	private String swfPath;//swf文件路径
	private String category;//分类
	private List<File> files;
	private String treeData;
	static ExecutorService service=Executors.newCachedThreadPool();
	
	@Autowired
	private FileAttachmentRepository fileAttachmentRepository;
	
	
	public void setFileAttachmentRepository(
			FileAttachmentRepository fileAttachmentRepository) {
		this.fileAttachmentRepository = fileAttachmentRepository;
	}
	/**
	 * 文件列表
	 * @return
	 */
	public String list(){
		//我的收藏列表
		if(File.FAVORITE.equals(curTab)){
			filePage=fileApplication.queryMyFavorite(getUserId(), currentPage, pageSize);
		}else{//其他列表：已通过，提交中，未通过
			filePage=fileApplication.queryPageByStatus(getUserId(),status, currentPage, pageSize);
		}
		return "list-file";
	}
	
	public String favorite(){
		filePage=fileApplication.queryMyFavorite(getUserId(), currentPage, pageSize);
		List<Long> cs=null;
		if(!isSuperAdmin()){
			cs=getUserCateIds();
		}
		cates1=categoryApplication.getCates(cs);
		return "favorite";
	}
	/**
	 * 管理员文件列表
	 * @return
	 */
	public String adminlist(){
		if(isSuperAdmin())
			filePage=fileApplication.queryPageByStatus(status, currentPage, pageSize,null,true);
		else
			filePage=fileApplication.queryPageByStatus(status, currentPage, pageSize,getAdminCateIds(),false);
		return "admin-file-list";
	}
	/**
	 * 删除提交中
	 * @return
	 */
	public String delUnApprove(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				String[] idArr=ids.split(",");
				fileApplication.batchDelete(idArr);
				jsonResult="删除成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 删除已提交
	 * @return
	 */
	public String delApprove(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				final String[] idArr=ids.split(",");
				for(String id:idArr){
					List<FileAttachment> list=fileAttachmentRepository.listAttachment(Long.parseLong(id), 1);
					for(FileAttachment a:list){
						java.io.File t=new java.io.File(config.getPersistFileStoreDirectory()+"/"+a.getAttachPath()+a.generateFileName());
						try {
							FileUtils.forceDelete(t);
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
				fileApplication.batchDelete(idArr);
				jsonResult="删除成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 删除提交中
	 * @return
	 */
	public String delSubmitting(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				final String[] idArr=ids.split(",");
				for(String id:idArr){
					List<FileAttachment> list=fileAttachmentRepository.listAttachment(Long.parseLong(id), 1);
					for(FileAttachment a:list){
						java.io.File t=new java.io.File(config.getTempFileStoreDirectory()+"/"+a.getAttachPath()+a.generateFileName());
						try {
							if(t.exists())
								FileUtils.forceDelete(t);
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
				fileApplication.batchDelete(idArr);
				jsonResult="删除成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 更改分类
	 * @return
	 */
	public String changeCate(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				String[] idArr=ids.split(",");
				fileApplication.changeCate(idArr,category);
				jsonResult="更改分类成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	public String moveFile(){
		try{
			if(StringUtils.isNotEmpty(fileId)){
				File f=fileApplication.showFile(Long.parseLong(fileId));
				News n=new News();
				n.setCanFaq(f.isCanFaq());
				n.setCanDown(f.isCanDown());
				n.setPublishTime(new Date());
				n.setSugestTime(new Date());
				n.setPublishUser(getUserId());
				n.setPublishUserName(getUserRealName());
				n.setBrowserNum(0);
				n.setFaqSum(0);
				n.setCategory(f.getCategory());
				n.setCategoryId(f.getCategoryId());
				n.setKeyword(f.getKeyword());
				n.setTitle(f.getFileName());
				NewsContent cont=new NewsContent();
				cont.setContent(f.getDesc());
				cont.setNews(n);
				Set<NewsContent> conts=new HashSet<NewsContent>();
				conts.add(cont);
				n.setContent(conts);
				n.setAttachments(f.getAttachments());
				for(FileAttachment a:f.getAttachments())
					FileHandle.move(config.getTempFileStoreDirectory(),config.getPersistFileStoreDirectory(), a);
				newsApplication.add(n);
				fileApplication.batchDelete(new String[]{fileId});
				jsonResult="保存成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 通过
	 * @return
	 */
	public String approve(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				final String[] idArr=ids.split(",");
				fileApplication.changeStatus(idArr,FileStatus.APPROVE);
				new Thread(new Runnable(){

					@Override
					public void run() {
						for(String id:idArr){
							List<FileAttachment> list=fileAttachmentRepository.listAttachment(Long.parseLong(id), 1);
							for(FileAttachment a:list){
								FileHandle.move(config.getTempFileStoreDirectory(), config.getPersistFileStoreDirectory(), a);
							}
						}
					}
					
				}).start();
				jsonResult="操作成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 不通过
	 * @return
	 */
	public String unApprove(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				final String[] idArr=ids.split(",");
				fileApplication.changeStatus(idArr,FileStatus.UNAPPROVE);
				new Thread(new Runnable(){

					@Override
					public void run() {
						for(String id:idArr){
							List<FileAttachment> list=fileAttachmentRepository.listAttachment(Long.parseLong(id), 1);
							for(FileAttachment a:list){
								java.io.File t=new java.io.File(config.getTempFileStoreDirectory()+"/"+a.getAttachPath()+a.generateFileName());
								try {
									FileUtils.forceDelete(t);
								} catch (IOException e) {
									e.printStackTrace();
								}
							}
						}
					}
					
				}).start();
				jsonResult="操作成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 删除我的收藏
	 * @return
	 */
	public String delFavorite(){
		try{
			if(StringUtils.isNotEmpty(ids)){
				String[] idArr=ids.split(",");
				fileApplication.batchDeleteFavorite(idArr);
				jsonResult="删除成功!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 检查文件是否已经存在
	 * @return
	 */
	public String checkFile(){
		try{
			if(StringUtils.isNotEmpty(fileName)){
				FileAttachment f=fileApplication.getFileByName(fileName);
				if(f==null){
					jsonCode="1";
					jsonResult="";
				}else{
					jsonCode="0";
					jsonResult="已经存在相同文件名的文件:"+f.getAttachName();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonCode="0";
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 上传我的文件页面
	 * @return
	 */
	public String gotoUpload(){
		tempFileId=UUID.randomUUID().toString().replaceAll("-", "");//生成临时文件ID 
		tempImageId=UUID.randomUUID().toString().replaceAll("-", "");
		List<Long> cs=null;
		if(!isSuperAdmin()){
			cs=getUserCateIds();
		}
		cates1=categoryApplication.getCates(cs);
		return "upload_file";
	}
	/**
	 * 上传管理员文件页面
	 * @return
	 */
	public String gotoAdminUpload(){
		tempFileId=UUID.randomUUID().toString().replaceAll("-", "");//生成临时文件ID 
		tempImageId=UUID.randomUUID().toString().replaceAll("-", "");
		return "admin_upload_file";
	}
	/**
	 * 上传页面
	 * @return
	 */
	public String gotoSingleUploadStep2(){
		return "single_upload_file_step2";
	}
	/**
	 * 管理员上传页面
	 * @return
	 */
	public String gotoAdminUploadStep2(){
		return "admin_upload_file_step2";
	}
	public String gotoNewsUploadStep2(){
		return "news_upload_file_step2";
	}
	public String gotoImageUploadStep2(){
		return "image_upload_file_step2";
	}
	public String gotoIconUploadStep2(){
		return "icon_upload_file_step2";
	}
	/**
	 * 保存文件
	 * @return
	 * @throws IOException 
	 */
	public String save() throws IOException{
		//保存文件
		file.setUploadUser(getUserId());
		file.setUploadTime(new Date());
		file.setStatus(FileStatus.SUBMITTING);//提交中
		file.setFolder(FileFolder.TEMP);//临时文件夹
		
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		List<FileAttachment> atts=new ArrayList<FileAttachment>();
		for(TempAttachment temp:tempAttachs){
			FileAttachment a=new FileAttachment();
			a.setAttachName(temp.getAttachName());
			a.setAttachPath(temp.getAttachPath());
			a.setAttachSize(temp.getAttachSize());
			a.setCheckSum(temp.getCheckSum());
			AttachmentType type=new AttachmentType();
			type.setName(temp.getAttachType());
			type.setIcon("");
			a.setAttachType(type);
			a.setGuid(temp.getGuid());
			file.setCanDown(temp.isCanDown());
			//a.setFile(file);
			atts.add(a);
		}
		file.setAttachments(atts);
		
		fileApplication.addFile(file);
		return "save-succuss";
	}
	public String myFileSave(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		for(File f:files){
			f.setUploadUser(getUserId());
			f.setPublishUser(getUserId());
			f.setPublishTime(new Date());
			f.setStatus(FileStatus.SUBMITTING);//提交中
			f.setFolder(FileFolder.TEMP);//临时文件夹
			f.setCanFaq(true);
			f.setCanDown(true);
			if(null==f.getCategoryId()){//did not choose category, set a default 
				f.setCategoryId(Constants.UPLOAD_DEFAULT_ID);
				f.setCategory(Constants.UPLOAD_DEFAULT_NAME);
			}
			List<FileAttachment> atts=new ArrayList<FileAttachment>();
			for(TempAttachment temp:tempAttachs){
				if(temp.getId().longValue()==f.getTempId().longValue()){
					FileAttachment a=new FileAttachment();
					a.setAttachName(temp.getAttachName());
					a.setAttachPath(temp.getAttachPath());
					a.setAttachSize(temp.getAttachSize());
					a.setCheckSum(temp.getCheckSum());
					AttachmentType type=new AttachmentType();
					type.setName(temp.getAttachType());
					type.setIcon("");
					a.setAttachType(type);
					a.setGuid(temp.getGuid());
					FileHandle.move(config.getUploadFileStoreDirectory(), config.getTempFileStoreDirectory(), a);
					//set image
					final List<TempAttachment>  tempImages=fileApplication.loadTempAttach(tempImageId);
					if(tempImages.size()>0){
						a.setPhotoName(tempImages.get(0).getGuid()+"."+tempImages.get(0).getAttachType());
						FileHandle.move(config.getUploadFileStoreDirectory(), config.getImageStoreDirectory(), tempImages.get(0));
					}
					atts.add(a);
					f.setAttachments(atts);
				}
			}
		}
		fileApplication.addFiles(files);
		List<Long> cs=null;
		if(!isSuperAdmin()){
			cs=getUserCateIds();
		}
		cates1=categoryApplication.getCates(cs);
		return "single_save_succuss";
	}
	
	/**
	 * 管理员保存文件
	 * @return
	 * @throws IOException 
	 */
	public String adminFileSave(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		for(File f:files){
			f.setUploadUser(getUserId());
			f.setPublishUser(getUserId());
			f.setPublishTime(new Date());
			f.setPublishUserName(getUserRealName());
			f.setStatus(FileStatus.APPROVE);
			if("on".equals(f.getCanFaqStr())){
				f.setCanFaq(true);
			}else{
				f.setCanFaq(false);
			}
			if("on".equals(f.getCanDownStr())){
				f.setCanDown(true);
			}else{
				f.setCanDown(false);
			}
			List<FileAttachment> atts=new ArrayList<FileAttachment>();
			for(TempAttachment temp:tempAttachs){
				//if(temp.getId().longValue()==f.getTempId().longValue()){
					FileAttachment a=new FileAttachment();
					a.setAttachName(temp.getAttachName());
					a.setAttachPath(temp.getAttachPath());
					a.setAttachSize(temp.getAttachSize());
					a.setCheckSum(temp.getCheckSum());
					AttachmentType type=new AttachmentType();
					type.setName(temp.getAttachType());
					type.setIcon("");
					a.setAttachType(type);
					a.setGuid(temp.getGuid());
					FileHandle.move(config.getUploadFileStoreDirectory(), config.getPersistFileStoreDirectory(), a);
					//set image
					final List<TempAttachment>  tempImages=fileApplication.loadTempAttach(temp.getGuid());
					if(tempImages.size()>0){
						a.setPhotoName(tempImages.get(0).getGuid()+"."+tempImages.get(0).getAttachType());
						FileHandle.move(config.getUploadFileStoreDirectory(), config.getImageStoreDirectory(), tempImages.get(0));
					}
					atts.add(a);
					f.setAttachments(atts);
				//}
			}
		}
		fileApplication.addFiles(files);
		return "admin-save-succuss";
	}
	/**
	 * 加载附件
	 * @return
	 */
	public String loadSingleTempAttach(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "single_attach";
	}
	/**
	 * 加载图片
	 * @return
	 */
	public String loadTempImage(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "image_attach";
	}
	public String loadTempIcon(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "icon_attach";
	}
	public String loadNewsTempImage(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "news_image_attach";
	}
	/**
	 * 加载附件
	 * @return
	 */
	public String loadAdminTempAttach(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		if(isSuperAdmin())
			treeData=categoryApplication.getJson(null);
		else
			treeData=categoryApplication.getJson(getUserCateIds());
		return "admin_attach";
	}
	public String loadNewsTempAttach(){
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "news_attach";
	}
	/**
	 * 删除附件
	 * @return
	 */
	public String delSingleTempAttach(){
		if(StringUtils.isNotEmpty(attachId))
		fileApplication.deleteAttach(Long.parseLong(attachId));
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "single_attach";
	}
	public String delTempImage(){
		if(StringUtils.isNotEmpty(attachId))
		fileApplication.deleteAttach(Long.parseLong(attachId));
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "image_attach";
	}
	/**
	 * 删除附件
	 * @return
	 */
	public String delAdminTempAttach(){
		if(StringUtils.isNotEmpty(attachId))
		fileApplication.deleteAttach(Long.parseLong(attachId));
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		if(isSuperAdmin())
			treeData=categoryApplication.getJson(null);
		else
			treeData=categoryApplication.getJson(getUserCateIds());
		return "admin_attach";
	}
	
	public String delNewsTempAttach(){
		if(StringUtils.isNotEmpty(attachId))
		fileApplication.deleteAttach(Long.parseLong(attachId));
		tempAttachs=fileApplication.loadTempAttach(tempFileId);
		return "news_attach";
	}
	/**
	 * 显示文件
	 * @return
	 */
	public String showFile(){
		if(StringUtils.isNotEmpty(fileId)){
			cates=categoryApplication.getRoots();
			file=fileApplication.showFile(Long.parseLong(fileId));
		}
		List<Long> cs=null;
		if(!isSuperAdmin()){
			cs=getUserCateIds();
		}
		cates1=categoryApplication.getCates(cs);
		return "file_show";
	}
	/**
	 * 显示编辑文件页面
	 * @return
	 */
	public String gotoEditFile(){
		if(StringUtils.isNotEmpty(fileId)){
			file=fileApplication.getFile(Long.parseLong(fileId));
		}
		return "edit-file";
	}
	/**
	 * 编辑文件提交
	 * @return
	 */
	public String editFile(){
		try{
			File dbFile=fileApplication.getFile(file.getId());
			dbFile.setFileName(file.getFileName());
			dbFile.setCategory(file.getCategory());
			dbFile.setDesc(file.getDesc());
			dbFile.setKeyword(file.getKeyword());
			dbFile.setCategoryId(file.getCategoryId());
			dbFile.setAttachPosition(file.getAttachPosition());
			dbFile.setEditTime(new Date());
			dbFile.setEditUser(getUserId());
			if("on".equals(file.getCanFaqStr())){
				dbFile.setCanFaq(true);
			}else{
				dbFile.setCanFaq(false);
			}
			if("on".equals(file.getCanDownStr())){
				dbFile.setCanDown(true);
			}else{
				dbFile.setCanDown(false);
			}
			fileApplication.saveOrUpdateFile(dbFile);
			jsonResult="保存成功!";
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	
	/**
	 * 添加收藏
	 * @return
	 */
	public String addFavorite(){
		try{
			UserFavorite uf=new UserFavorite();
			uf.setFileId(Long.parseLong(fileId));
			fileApplication.addFavorite(uf,getUserId());
			jsonResult="保存成功!";
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(),e);
			jsonResult="出错："+e.getMessage();
		}
		return JSON;
	}
	/**
	 * 预览
	 * @return
	 * @throws IOException 
	 */
	public String preview() throws IOException{
		try{
			atts=fileApplication.getAttachment(Long.parseLong(attachId));
			if(atts.isImage()){
				path=config.getMappingIp()+config.getPathPersist()+atts.getAttachPath()+atts.generateFileName();
				return "preview_image";
			}
			if(atts.isText()){
				txtContents=FileUtils.readLines(new java.io.File(config.getPersistFileStoreDirectory()+java.io.File.separator+atts.getAttachPath()+atts.generateFileName()));
				return "preview_txt";
			}
			if(atts.isSwf()){
				path=config.getMappingIp()+config.getPathPersist()+atts.getAttachPath()+atts.getGuid()+".swf";
				return "preview_swf";
			}
			if(atts.isConvertedSwf()){
				if(atts.isConvertOk() || atts.isMoveToOk()){//程序转换的
					String destDesk = config.getSwfFileStoreDirectory()
					+ java.io.File.separator + atts.getGuid();
					java.io.File desk=new java.io.File(destDesk);
					path="{"+config.getMappingIp()+config.getPathSwf()+atts.getGuid()+ "/"+"[*,0].swf,"+desk.listFiles().length+"}";
					return "preview_pdf";
				}
			}
			if (atts.isPdf() && !"1".equals(atts.getConvertError())) {// 没找到SWF才去转换
				if("0".equals(atts.getConvertError())){
					jsonResult="正在转换文件格式，请稍后再访问";
					return "file_not_found";
				}
				Thread t=new Thread(new Runnable(){

					@Override
					public void run() {
						ConvertFileThread task=new ConvertFileThread(getConfig(),atts.getAttachPath(),atts.getGuid(),atts.getAttachType().getName(),fileApplication);
						Future<Boolean> result=ExecutorUtil.getExecutor().submit(task);
						try {
							result.get(5,TimeUnit.HOURS);
						} catch (InterruptedException e) {
							e.printStackTrace();
						} catch (ExecutionException e) {
							e.printStackTrace();
						} catch (TimeoutException e) {
							e.printStackTrace();
							java.io.File oFile=new java.io.File(config.getSwfFileStoreDirectory()+java.io.File.separator+atts.getGuid()+ java.io.File.separator+"1.swf");
							if(!oFile.exists()){
								atts=fileApplication.getAttachment(atts.getId());
								atts.setConvertError("1");
								atts.setConvertOk(false);
								fileApplication.saveOrUpdateFileAttachment(atts);
							}
						}
					}
					
				});
				t.setDaemon(true);
				t.start();
				jsonResult="正在转换文件格式，请稍后再访问";
			}
			return "file_not_found";
		}catch(Exception e){
			e.printStackTrace();
			return "file_not_found";
		}
	}
	
	@Override
	public String getParam() {
		return "curTab="+curTab+"&status="+status;
	}


	private String txtContent;
	private List<String> txtContents;
	private FileAttachment atts;
	private List<Category> cates;
	private String tempImageId;
	
	private String path;
	private List<JsonCategory> cates1;
	
	
	
	public List<String> getTxtContents() {
		return txtContents;
	}
	public void setTxtContents(List<String> txtContents) {
		this.txtContents = txtContents;
	}
	public List<JsonCategory> getCates1() {
		return cates1;
	}
	public void setCates1(List<JsonCategory> cates1) {
		this.cates1 = cates1;
	}
	public String getTempImageId() {
		return tempImageId;
	}
	public void setTempImageId(String tempImageId) {
		this.tempImageId = tempImageId;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}
	public List<Category> getCates() {
		return cates;
	}
	public void setCates(List<Category> cates) {
		this.cates = cates;
	}
	public FileAttachment getAtts() {
		return atts;
	}
	public void setAtts(FileAttachment atts) {
		this.atts = atts;
	}
	public String getTxtContent() {
		return txtContent;
	}
	public void setTxtContent(String txtContent) {
		this.txtContent = txtContent;
	}
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}


	public Page<File> getFilePage() {
		return filePage;
	}

	public void setFilePage(Page<File> filePage) {
		this.filePage = filePage;
	}

	public String getCurTab() {
		return curTab;
	}

	public void setCurTab(String curTab) {
		this.curTab = curTab;
	}

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}
	public String getJsonResult() {
		return jsonResult;
	}
	public void setJsonResult(String jsonResult) {
		this.jsonResult = jsonResult;
	}
	public File getFile() {
		return file;
	}
	public void setFile(File file) {
		this.file = file;
	}
	public String getTempFileId() {
		return tempFileId;
	}
	public void setTempFileId(String tempFileId) {
		this.tempFileId = tempFileId;
	}
	public List<TempAttachment> getTempAttachs() {
		return tempAttachs;
	}
	public void setTempAttachs(List<TempAttachment> tempAttachs) {
		this.tempAttachs = tempAttachs;
	}
	public String getAttachId() {
		return attachId;
	}
	public void setAttachId(String attachId) {
		this.attachId = attachId;
	}
	public String getFileId() {
		return fileId;
	}
	public void setFileId(String fileId) {
		this.fileId = fileId;
	}
	public String getSwfPath() {
		return swfPath;
	}
	public void setSwfPath(String swfPath) {
		this.swfPath = swfPath;
	}
	public FileManagerConfig getConfig() {
		return config;
	}
	public void setConfig(FileManagerConfig config) {
		this.config = config;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public List<File> getFiles() {
		return files;
	}
	public void setFiles(List<File> files) {
		this.files = files;
	}
	public String getTreeData() {
		return treeData;
	}
	public void setTreeData(String treeData) {
		this.treeData = treeData;
	}
	public void setCategoryApplication(CategoryApplication categoryApplication) {
		this.categoryApplication = categoryApplication;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getJsonCode() {
		return jsonCode;
	}
	public void setJsonCode(String jsonCode) {
		this.jsonCode = jsonCode;
	}
	public void setNewsApplication(NewsApplication newsApplication) {
		this.newsApplication = newsApplication;
	}
	
	
	
}
